function Misil(enemy)
{
  var _x;
  var _y;
  var _destx;
  var _desty;
  var _type;
  var _root;
  var _speed;
  var _energy;
  var _tower;
  var _enemy;
  
  this._enemy = enemy;
}

Misil.prototype.Init = function(tower, x, y, type)
{
  this._x = x;
  this._y = y;
  this._type = type;
  this._speed = 12;
  this._energy = 20;
  this._tower = tower;
  
  this._root = new MovieClip();
  
  //hacer - decido el gráfico segun el tipo
  this._root.DrawCircle(0, 0, 2, '#420545', 1, '#020505', 1);
  this._root.x = this._x;
  this._root.y = this._y;
}

Misil.prototype.SetDestiny = function(dx, dy)
{
  this._destx = dx;
  this._desty = dy;
}

Misil.prototype.Work = function()
{
  //log(this._destx + " " + this._destx);
  
  if(this._x >= this._destx - this._speed &&
     this._x <= this._destx + this._speed &&
     this._y >= this._desty - this._speed &&
     this._y <= this._desty + this._speed)
  {
    this._tower.MisilExploded(this, this._enemy);
    this._enemy.Hit(this);
    return;
  }

  //ang a radianes 30*Math.PI/180  
  var ang = Math.atan2(this._destx - this._root.x, this._desty - this._root.y)
  var incx = Math.sin(ang) * this._speed;
  var incy = Math.cos(ang) * this._speed;
  
  this._root.x += incx;
  this._root.y += incy;
  
  this._x = this._root.x;
  this._y = this._root.y;
}

Misil.prototype.toString = function()
{
  return "[Misil]";
}